#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "hidapi.h"
#include "hiddevice.h"
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    unsigned short CRC16ByTable(unsigned char *pchMsg, unsigned short wDataLen);
    ~MainWindow();
void initDevice();
private slots:
    void writeData();
    void readData();
    void handleReceivedData(const QByteArray &data);
    void handleError(const QString &errorMessage);
    void handleDisconnect();

private:
    Ui::MainWindow *ui;
    HIDDevice* m_device;  // HID设备对象
    void connectToDevice();  // 连接设备的方法
};

#endif // MAINWINDOW_H
